#include <stdio.h>

// 位域变量
typedef struct
{
    unsigned char bit1 : 1;
    unsigned char bit2 : 1;
    unsigned char bit3 : 1;
    unsigned char bit4 : 1;
    unsigned char bit5 : 1;
    unsigned char bit6 : 1;
    unsigned char bit7 : 1;
    unsigned char bit8 : 1;
    // unsigned char bit9 : 1;
} Byte;

int main()
{
    Byte B;
    int i;

    for (i = 0; i < 8; i++)
    {
        unsigned char value = 0x80 >> i;
        unsigned char and_result = value & 0x40;
        B.bit1 = and_result;
        printf("移位值：0x%02X ", value);
        printf("按位与结果：0x%02X ", and_result);
        printf("位域值：%d\n", B.bit1);
    }

    // printf("%zu\n", sizeof(Byte));

    return 0;
}